﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace PingYou.Framework.UI
{
    public class DemoController : ApiController
    {
        #region 获取段路径地址
        /// <summary>
        /// 获取段路径地址
        /// </summary>
        /// <param name="longUrl"></param>
        /// <returns></returns>
        [HttpGet]
        public dynamic GetShortUrl(string longUrl)
        {
            string result = string.Empty;
            try
            {
                result = CommonMethod.GetShortUrl(longUrl);
                return new
                {
                    success = true,
                    data = result
                };
                //string url = "http://xzl.zjzdy.net/" + result;
            }
            catch (Exception myEx)
            {
                return new { success = false, Message = myEx.Message };
            }

        }
        #endregion

        #region 获取段路径地址
        //[HttpGet]
        //public string GetLongUrl(string shortUrl)
        //{
        //    string result = string.Empty;
        //    try
        //    {
        //        result = CommonMethod.GetLongUrl(shortUrl);
        //    }
        //    catch (Exception myEx)
        //    {
        //        throw myEx;
        //    }
        //    return result;
        //}
        #endregion
    }
}